x = dfw.mon
plotts.sample.wge(x)$xbar[1] 65.9918
x = dfw.mon
plotts.sample.wge(x)$xbar[1] 65.9918
The Parzen spectral density plot shows peaks at approximately 0.08 and 0.18 which correspond with periods of 12 and 5.5 months. The 12 month period is corroborated by the sample autocorrelation plot, and makes sense given the seasonality of the data. The 5.5 month peak does not show up in the autocorrelation and may just be noise.
x = wtcrude2020
plotts.sample.wge(x)$xbar[1] 47.47493
The spectral density plot shows a peak at zero and the autocorrelation remains high across a large range of lags This is consistent with wandering data, which the oil prices appear to be.
x = sunspot2.0
plotts.sample.wge(x)$xbar[1] 78.51713
The spectral density plot shows peaks at approximately 0, 0.10, and 0.16. These correspond to a cycle of 10 years, 6 years, and some wandering behavior. The autocorrelation plot shows a pseudo-periodic cycle of approximately 10 years.
x = llynx
plotts.sample.wge(x)$xbar[1] 2.903664
The spectral density plot and autocorrelation plot both show evidence of a cycle of approximately 10 years. This seems consistent with the sample data.
x = doppler
plotts.sample.wge(x)$xbar[1] 0.02016438
The spectral density plot shows a series of small peaks, decreasing in size. The autocorrelation plot shows slowly decreasing autocorrelation with no evidence of cyclic behavior. There is clearly a cycle in the sample data, but it’s period seems to be increasing over time. Because of this, it makes sense that there is no frequency evident in the spectral density plot and the results appear somewhat confusing.
f = gen.arma.wge(n = 200, phi = c(2.55,-2.42,.855), mu = 10, sn = 7285)plotts.sample.wge(f)$xbar[1] 15.09827
The spectral density plot shows a peak at zero and 0.10. The autocorrelation plot shows evidence of a cycle with period of approximately 10. This is consistent with the sample data which shows both wandering behavior and a cycle with a period of approximately 10.
f = gen.arma.wge(n = 200, phi = c(0.65, 0.62, -.855), mu = 50, sn = 5698)plotts.sample.wge(f)$xbar[1] 50.10339
The spectral density plot shows a peak at about 0.8, which corresponds to the period of approximately 12 which appears in the autocorrelation plot. There is also the start of a peak at the right side of the spectral density plot, which may correspond to the small high-frequency oscillation which appears in the sample data.
h = gen.sigplusnoise.wge(n = 250, coef = c(2, 1), freq = c(0.05, 0.28), psi = c(1.2, 2), phi = 0.9, sn = 278)plotts.sample.wge(h)$xbar[1] 1.023251
The spectral density plot shows peaks around 0.05 and 0.3. The data appears to be cyclic with a cycle of period approximately 12, overlaid with a high-frequency oscillation. The autocorrelation plot shows a cycle of period approximately 8-14, but it is obscured by the high frequency cycle.
Time Series 1:
Time Series 2:
Time Series 3:
Time Series 4:
y = gen.sigplusnoise.wge(n = 100, coef = c(2, 0), freq = c(0.1, 0), psi = c(0, 0), phi = 0, sn = 17)x(t)=coef[1]*cos(2*pi*freq[1]*t+psi[1])+coef[2]*cos(2*pi*freq[2]*t+psi[2])+a(t)
Plot the data:
plotts.sample.wge(y)$xbar[1] 0.1380363
y_filt = butterworth.wge(y, type = "high", cutoff = 0.5, plot = TRUE)The filtered data is zero for the entire time series. This means that there are no frequencies greater than 0.5 in the original time series.
y_filt = butterworth.wge(y, type = "low", cutoff = 0.5, plot = TRUE)In this case, the filtered data looks the same as the original data. This means that there are no cycles with frequency greater than 0.5 in the time series.
y_filt = butterworth.wge(y, type = "high", cutoff = 0.15, plot = TRUE)The filtered data this time shows a relatively low amplitude cycle with period of approximately 2.
y_filt = butterworth.wge(y, type = "low", cutoff = 0.15, plot = TRUE)The filtered data below the cutoff of 0.15 shows a smooth function resembling a sine wave with period of approximately 15.
y_filt = ma.smooth.wge(y, order = 5, plot = FALSE)3 -0.7654403 t.start,x.sm
plot(y_filt$smooth, type = 'l', xlab = 'Moving Average Smoother (order = 5)')The output of the moving average smoother appears similar to the output of the low-pass Butterworth filter with 0.15 cutoff.
x = gen.arma.wge(n = 50, phi = c(1.83000, -1.97500, 1.82085, -0.97510), sn = 2787)plotts.sample.wge(x)$xbar[1] -0.5370972
parzen.wge(x)$freq
[1] 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30
[16] 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50
$pzgram
[1] 2.3423900 3.2613584 3.6561646 3.1773233 1.7374652 -0.6691424
[7] -3.7432312 -5.1836379 -2.6570157 0.4749840 2.6460590 3.7431942
[13] 3.8033744 2.8428528 0.8603502 -2.0884018 -5.6165215 -8.5725214
[19] -10.0784104 -10.8092699 -11.2288570 -11.4135906 -11.5927548 -11.8510842
[25] -11.9884070
The realization shows cyclic behavior with period of approximately 4. The spectral density plot displays the cycle as a peak at 0.25, but also picks up another frequency at about 0.05, which would correspond to a period of 20. This second cycle is not obvious in the realization.
Low-pass Butterworth with cutoff 0.12:
x_filt = butterworth.wge(x, type = "low", cutoff = 0.12, plot = TRUE)The low-pass filter outputs a smoothed version of the original time series. There appears to be periodic behavior around the 0.05 frequency, but it is not very regular. The amplitude of the cycle also changes with time. This does explain the first peak in the spectral density plot.
x_filt = butterworth.wge(x, type = "high", cutoff = 0.12, plot = TRUE)Here we see the cycle with period of 4. This is the second peak in the spectral density plot. It appears to be regular in amplitude.
x_filt = butterworth.wge(x, type = "low", cutoff = 0.23, plot = TRUE)This filter maintains the structure with the longer period (or wandering behavior), but smooths the cycle with period 4. Unlike the 0.12 filter, the higher frequency cycle is still evident in the filtered data. The cutoff of 0.23 likely attenuates the cycle by being close enough but not at the true frequency.
x_filt = butterworth.wge(x, type = "high", cutoff = 0.07, plot = TRUE)The output of this filter looks almost identical to the 0.12 filter. The higher frequency cycle is evident with some slight low frequency movement. Although the filter is the same distance away from the true frequency as the 0.23 filter, much less of the cycle makes it through. I would speculate that this means the cycle with frequency 0.05 may be more related to noise than anything in the generating function.
x_filt = butterworth.wge(x, type = "low", cutoff = 0.3, plot = TRUE)The filtered data is the same as the original data. This means there are no frequencies greater than 0.3 in the original data, which is consistent with the spectral density plot.
x_filt = butterworth.wge(x, type = "high", cutoff = 0.3, plot = TRUE)The filtered data shows a straight line at 0 dB with some end effects present. There is some oscillation present, but I believe that to be an artifact of the filter rather than the sample data. That said, it does have a period of approximately four, which is suspicious because it should be filtered out. The end effects might be compensated for by truncating the range we look at for filtered data.
x = gen.arima.wge(50, phi = -0.99, sn = 1)acf(x, lag.max = 20)# parzen.wge(x)x = gen.arima.wge(100, phi = 0, s = 4, sn = 1)acf(x, lag.max = 20)parzen.wge(x)$freq
[1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15
[16] 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30
[31] 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45
[46] 0.46 0.47 0.48 0.49 0.50
$pzgram
[1] -17.1985101 -17.6812693 -18.4103697 -19.3036699 -20.2917610 -21.2824323
[7] -22.0360955 -22.2010088 -21.7887861 -21.3118148 -21.2392579 -21.6685231
[13] -22.2169367 -22.2231518 -21.6164335 -20.5132059 -17.9097853 -13.7553755
[19] -9.5744334 -6.0762611 -3.3352154 -1.2882819 0.1307694 0.9687223
[25] 1.2525151 0.9920847 0.1830949 -1.1900669 -3.1477702 -5.6921135
[31] -8.7138994 -11.6733064 -13.2984330 -13.1724607 -12.5470210 -12.2715111
[37] -12.4614390 -12.7544145 -12.5970975 -11.9339543 -10.8114118 -8.2877172
[43] -4.2509150 -0.1233558 3.3603845 6.0988897 8.1444383 9.5598844
[49] 10.3913350 10.6655811
valencia = read.csv("Valencia_laptimes.csv", header = TRUE)
x = as.numeric(paste(valencia$Time))
plotts.sample.wge(x)$xbar
[1] 90.87752
$autplt
[1] 1.00000000 0.70857148 0.50694937 0.36615644 0.27988541 0.22041269
[7] 0.21861259 0.29634847 0.13552464 0.02469633 -0.13240267 -0.22119416
[13] -0.33720228 -0.38510215 -0.34767096 -0.26626761 -0.16820471 -0.23797570
[19] -0.24100874 -0.29692564 -0.28373665 -0.22449630 -0.11496984
$freq
[1] 0.04347826 0.08695652 0.13043478 0.17391304 0.21739130 0.26086957
[7] 0.30434783 0.34782609 0.39130435 0.43478261 0.47826087
$dbz
[1] 5.205887 3.499821 1.202835 -1.089614 -3.080975 -4.503124 -5.461298
[8] -6.395323 -7.009037 -7.182661 -7.330258
# plot valencia data and acf with ggplot
ggplot(valencia, aes(x = Year, y = Time)) +
geom_line() + # or geom_point() for scatter plot
theme_minimal() +
labs(title = "Best Valencia Lap Time by Year",
x = "Year",
y = "Lap Time")acf(valencia$Time, main = "ACF of Lap Times")parzen.wge(valencia$Time)$freq
[1] 0.04347826 0.08695652 0.13043478 0.17391304 0.21739130 0.26086957
[7] 0.30434783 0.34782609 0.39130435 0.43478261 0.47826087
$pzgram
[1] 5.205887 3.499821 1.202835 -1.089614 -3.080975 -4.503124 -5.461298
[8] -6.395323 -7.009037 -7.182661 -7.330258